package com.qys.livesMall.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qys.livesMall.shop.modal.entity.ShopOrderComment;
import com.qys.livesMall.shop.mapper.ShopOrderCommentMapper;
import com.qys.livesMall.shop.service.ShopOrderCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品评论表 服务实现类
 * </p>
 *
 * @author gmx
 * @since 2023-06-30
 */
@Service
public class ShopOrderCommentServiceImpl extends ServiceImpl<ShopOrderCommentMapper, ShopOrderComment> implements ShopOrderCommentService {

    @Override
    public List<ShopOrderComment> queryComment(Long orderId) {
        LambdaQueryWrapper<ShopOrderComment> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(ShopOrderComment::getOrderId,orderId);
        List<ShopOrderComment> list = super.list(lambdaQueryWrapper);
        return list;
    }

    @Override
    public boolean haveLiked(Long commentId, Long userId) {
        int count = baseMapper.haveLiked(commentId, userId);
        return count > 0;
    }

    @Override
    public void saveLike(Long commentId, Long userId) {
        baseMapper.saveLike(commentId, userId);
    }
}
